﻿using System;
using System.Windows.Forms;
using RabbitMQ.Client;

namespace Spade
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void TransferButton_Click(object sender, EventArgs e)
        {
            var factory = new ConnectionFactory();
            factory.Uri = string.Format("{0}", BrokerUri.Text);
            using (var conn = factory.CreateConnection())
            {
                using (var channel = conn.CreateModel())
                {
                    BasicGetResult result;
                    while ((result = channel.BasicGet(SourceQueue.Text, true)) != null)
                    {
                        channel.BasicPublish(DestinationQueue.Text, result.RoutingKey, result.BasicProperties, result.Body);
                    }
                }
            }
        }
    }
}
